import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ClassBookVO, ClassBookForm, ClassBookQuery } from '@/api/attendance/class/book/types';

/**
 * 查询班级点名册列表
 * @param query
 * @returns {*}
 */

export const listClassBook = (query?: ClassBookQuery): AxiosPromise<ClassBookVO[]> => {
  return request({
    url: '/attendance/class/book/list',
    method: 'get',
    params: query
  });
};

export const listClassBook4Call = (query?: ClassBookQuery): AxiosPromise<ClassBookVO[]> => {
  return request({
    url: '/attendance/class/book/call-list',
    method: 'get',
    params: query
  });
};

export const pageClassBookCall = (query?: ClassBookQuery): AxiosPromise<ClassBookVO[]> => {
  return request({
    url: '/attendance/class/book/call-page',
    method: 'get',
    params: query
  });
};

export const callClassBook = (data: any) => {
  return request({
    url: '/attendance/class/book/call',
    method: 'post',
    data: data
  });
};

/**
 * 查询班级点名册详细
 * @param id
 */
export const getClassBook = (id: string | number): AxiosPromise<ClassBookVO> => {
  return request({
    url: '/attendance/class/book/' + id,
    method: 'get'
  });
};

/**
 * 新增班级点名册
 * @param data
 */
export const addClassBook = (data: ClassBookForm) => {
  return request({
    url: '/attendance/class/book',
    method: 'post',
    data: data
  });
};

/**
 * 修改班级点名册
 * @param data
 */
export const updateClassBook = (data: ClassBookForm) => {
  return request({
    url: '/attendance/class/book',
    method: 'put',
    data: data
  });
};

/**
 * 删除班级点名册
 * @param id
 */
export const delClassBook = (id: string | number | Array<string | number>) => {
  return request({
    url: '/attendance/class/book/' + id,
    method: 'delete'
  });
};
